package com.gsafety.wellsfort.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gsafety.wellsfort.common.enums.CustomerTypeEnum;
import com.gsafety.wellsfort.domain.model.course.Course;
import com.gsafety.wellsfort.domain.model.course.CourseRange;
import com.gsafety.wellsfort.domain.model.course.LessonPeriod;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import javax.crypto.spec.PSource;
import java.util.Date;
import java.util.List;

@Data
@ApiModel(value = "课程详情")
public class CourseDetailVO {
    private Integer id;

    @ApiModelProperty(value = "课程对象值")
    private Integer objectType;
    @ApiModelProperty(value = "课程对象名称")
    private String objectTypeText;

    @ApiModelProperty(value = "课程名称")
    private String name;

    @ApiModelProperty(value = "课程简介")
    private String introduction;

    @ApiModelProperty(value = "课程图URL")
    private String imageUrl;

    @ApiModelProperty(value = "缩略图URL")
    private String thumbnailUrl;

    @ApiModelProperty(value = "0，线上，1，线下")
    private Byte teachingWay;

    @ApiModelProperty(value = "上线时间")
    private Date attendClassTime;

    @ApiModelProperty(value = "是否上线:1,是.0 否")
    private Integer isOnline;

    @ApiModelProperty(value = "上线时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date onlineTime;

    @ApiModelProperty(value = "课程时长")
    private Integer duration;

    @ApiModelProperty(value = "课程范围")
    List<CourseRange> courseRangeList;

    @ApiModelProperty(value = "课时列表")
    List<LessonPeriod> lessonPeriodList;

    @ApiModelProperty(value = "学习进度")
    private String rate;

    @ApiModelProperty(value = "学校名称")
    private String schoolName;

    @ApiModelProperty(value = "班级名称")
    private String className;

    @ApiModelProperty(value = "学生总数")
    private Integer studentNumber;

    public static class VOBuilder {
        Course course;
        CourseDetailVO courseVO = new CourseDetailVO();

        public VOBuilder(Course q) {
            this.course = q;
        }

        public CourseDetailVO build() {
            if (course != null) {
                BeanUtils.copyProperties(course, courseVO);
                courseVO.setObjectTypeText(CustomerTypeEnum.parseVal(courseVO.getObjectType()).label);
            }
            return courseVO;
        }
    }
}
